# -*- coding: utf-8 -*-

from MongoJob import MongoJob
import queue

class HostsBruteJob(MongoJob):
	getLimit = 10
	
	collection_name = 'hosts_brute_names'
	
	def build_row(self, str):
		return {"name": str.strip(),	
				"checked": 0,
				"getted": 0}
	
	def get_nowait(self, timeout=None):
		return self.get(False, timeout)
	
	def get(self, block=True, timeout=None):
		result = []
		while True:
			try:
				row = super().get(block, timeout)
				if len(row.strip()) > 0:
					result.append(row.lower().strip())
				if len(result) == self.getLimit:
					break
			except queue.Empty:
				break
		return result
		